{% extends 'base_backend.html' %}
{% load static %}
{% load my_filter %}

{% block header_tail %}
<link rel="stylesheet" href="{% static 'zhongbao/zhongbao_admin/css/style.css' %}">
<link rel="stylesheet" href="{% static 'zhongbao/zhongbao_admin/css/iconfont.css' %}">
<link rel="stylesheet" href="{% static 'plugins/datatables/dataTables.bootstrap.css' %}">
<link rel="stylesheet" href="{% static 'public/ComboSelect/css/combo.select.css' %}">
<link rel="stylesheet" href="{% static 'zhongbao/config/css/main.css' %}">

{% endblock header_tail %}

{% block section_content %}
    <div class="box-header with-border">
    <h3 class="box-title">奖励任务</h3>
    </div>
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <div class="box box-primary">
                <!-- /.box-header -->
                <div class="box-body no-padding">
                    <table class="table table-condensed text-center table-hover">
                        <tr>
                            <th>任务类型</th>
                            <th>任务内容</th>
                            <th>赏金</th>
                            <th>完成次数</th>
                            <th>完成状态</th>
                            <th>操作</th>
                        </tr>

                        <tr>
                            <td>新手任务</td>
                            <td>介绍主功能<span data-toggle="tooltip" title="为新手用户通过引导的方式，介绍众包的各个功能"><i class="fa fa-question-circle"></i></span></td>
                            <td><p class="text-green">+2.00</p></td>
                            {% if data.newbies.1 %}
                                <td>(1/1)</td>
                                <td>已完成</td>
                                <td><button type="button" class="btn btn-info btn-xs" value="1" disabled>已完成</button></td>
                            {% else %}
                                <td>(0/1)</td>
                                <td>未完成</td>
                                <td>
                                    <button type="button" class="btn btn-info btn-xs" value="1" onclick="goto_task('1')">前往任务</button>
                                    <button type="button" class="btn btn-info btn-xs" value="1">忽略任务</button>
                                </td>
                            {% endif %}
                        </tr>

                        <tr>
                            <td>新手任务</td>
                            <td>任务操作步骤<span data-toggle="tooltip" title="为新手用户通过引导的方式，介绍任务的领取提交的操作"><i class="fa fa-question-circle"></i></span></td>
                            <td><p class="text-green">+5.00</p></td>
                            {% if data.newbies.2 %}
                                <td>(1/1)</td>
                                <td>已完成</td>
                                <td><button type="button" class="btn btn-info btn-xs" value="1" disabled>已完成</button></td>
                            {% else %}
                                <td>(0/1)</td>
                                <td>未完成</td>
                                <td>
                                    <button type="button" class="btn btn-info btn-xs" value="1" onclick="goto_task('2')">前往任务</button>
                                    <button type="button" class="btn btn-info btn-xs" value="1">忽略任务</button>
                                </td>
                            {% endif %}
                        </tr>

                        <tr>
                            <td>活动任务</td>
                            <td>注册邀请 <span data-toggle="tooltip" title="将你的专属推荐链接分享给别人进行注册，成功注册达到一定数量后，你可以获得相应的推荐赏金哦！"><i class="fa fa-question-circle"></i></span></td>
                            <td><p class="text-green">+{{ data.invite_reward }}</p></td>
                            <td>({{ leninvi }}/{{ data.invite_goals }})</td>
                            <td>未完成</td>
                            <td><a href="{% url 'zhongbao_admin:invitation_register' %}" type="button" class="btn btn-info btn-xs" value="1">前往任务</a></td>
                        </tr>
                    </table>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </div>
    </div>

<script>

    //弹出框
    $(function (){
        $(".example").popover({trigger: 'hover'});
    });

    function changeColor(id, color) {
        //$(id).parent().parent().parent().children().children().children().find("li[color='green']");
        $(id).parent().parent().addClass("active");
        $(id).children().css("color", color);
    }

    $('#myTasks').addClass("active");
    changeColor("#reward_task", "#00FF7F");

    function setCookie(key,value,t) {
        var oDate=new Date();
        oDate.setDate(oDate.getDate()+t);
        document.cookie=key+"="+value+"; expires="+oDate.toDateString()+"; path=/task";
    }

    function goto_task(task_id) {
        setCookie("NewbieSkip","",-1);
        if(task_id == '1'){
            var url ="{% url 'task:index' %}";
        }else if(task_id == '2'){
            var url = "{% url 'task:accept' %}";
        }
        window.location.replace(url);
    }
</script>
{% endblock section_content %}

